package com.im;

import java.util.Locale;

// 程序入口
class Main {
    @SuppressWarnings("resource")
    public static void main(String[] args) {
        try {
            // 创建服务
            final Server server = new Server();

            // 开启服务
            boolean result = server.start();
            if (!result) {
                System.out.println("Start server failed.");
                return;
            }

            // 显示 IP 地址和端口号
            final String serverAddress = String.format(Locale.getDefault(),
                "IP: %s\nPort: %d", server.getLocalSocketAddress().toString(), server.getLocalPort());
            System.out.println(serverAddress);
        } catch (Exception e) {
            System.out.println("Start server failed.");
        }
    }
}
